﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;


namespace websitev2.Controllers
{
    public class DetailStatsController : Controller
    {
        //
        // GET: /DetailStats/
        public Models.StartStopEntities db = new Models.StartStopEntities();

       

        public ActionResult Index(string id, string id2)
        {

            // Load the user. 
            var user = db.ssUsers.FirstOrDefault(u => u.UserName == id);

            ViewBag.Viewing = id2; 

                // Load the general information 
                Models.UserGeneralInformationModel oUserGen = new Models.UserGeneralInformationModel();
                oUserGen = websitev2.Core.UserCore.LoadUserGen(user.UserGUID.GetValueOrDefault());
                ViewBag.UserGen = oUserGen;
                ViewBag.MediumAvatar = Core.UserCore.ReturnAvatarURL(user.UserGUID.GetValueOrDefault(), 1);

                StartStop.ServiceResources.UserStatLogWithDetail oDetail = new StartStop.ServiceResources.UserStatLogWithDetail();
                Guid _OverviewGUID = StartStop.Helpers.UserStatLog.ReturnOverGUIDfromOverviewTitle(id2);
                if (_OverviewGUID != Guid.Empty)
                {
                    // The ID has been found

                    
                    oDetail = StartStop.Helpers.UserStatLog.ReturnUserStatLogWithDetail(user.UserID, _OverviewGUID); 
                }
                else
                {
                    // HEre we should fling them to the another page but that's not build yet, so lets do....
                    // Nothing! 
                }

                #region SEO
                ViewBag.Title = id2.ToString()+" detailed stats for " + id + " | Startstop.me, all your stats in one place";
                #endregion 

                return View(oDetail); 
        }

    }
}
